New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tonal-note

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tonal-note

Encode pitches using fifths/octaves

  • 0.68.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
288
decreased by-56.43%
Maintainers
1
Weekly downloads
 
Created
Source

tonal-note npm version

tonal

tonal-note is a collection of functions to extract properties from musical notes.

This is part of tonal music theory library.

You can install via npm: npm i --save tonal-note

Read the generated API documentation.

API

tonal-note is a collection of functions to get properties from musical notes.

Example

var note = require('tonal-note')
note.name('bb2') // => 'Bb2'
note.chroma('bb2') // => 10
note.enharmonics('C#6') // => [ 'B##5', 'C#6', 'Db6' ]
note.simplify('B#3') // => 'C4'

note.chroma(note) ⇒ Integer

Return the chroma of a note. The chroma is the numeric equivalent to the pitch class, where 0 is C, 1 is C# or Db, 2 is D... 11 is B

Kind: static method of note
Returns: Integer - the chroma

ParamType
noteString | Pitch

Example

['C', 'D', 'E', 'F'].map(_.chroma) // => [0, 2, 4, 5]
_.map(_.chroma, 'cb db eb fb') // => [11, 1, 3, 4]

note.name(n) ⇒ String

Given a note (as string or as array notation) returns a string with the note name in scientific notation or null if not valid note

Kind: static method of note

ParamType
nPitch | String

Example

import { noteName } from 'tonal-notes'
['c', 'db3', '2', 'g+', 'gx4'].map(noteName)
// => ['C', 'Db3', null, null, 'G##4']

Example

var tonal = require('tonal')
tonal.noteName('cb2') // => 'Cb2'
tonal.map(tonal.noteName, 'c db3 2 g+ gx4') // => [ 'C', 'Db3', null, null, 'G##4' ]

note.pc(n) ⇒ String

Get pitch class of a note. The note can be a string or a pitch array.

Kind: static method of note
Returns: String - the pitch class

ParamType
nString | Pitch

Example

tonal.pc('Db3') // => 'Db'
tonal.map(tonal.pc, 'db3 bb6 fx2') // => [ 'Db', 'Bb', 'F##']

note.enharmonics(note) ⇒ Array

Get the enharmonics of a note. It returns an array of three elements: the below enharmonic, the note, and the upper enharmonic

Kind: static method of note
Returns: Array - an array of pitches ordered by distance to the given one

ParamTypeDescription
noteStringthe note to get the enharmonics from

Example

var note = require('tonal-note')
note.enharmonics('C') // => ['B#', 'C', 'Dbb']
note.enharmonics('A') // => ['G##', 'A', 'Bbb']
note.enharmonics('C#4') // => ['B##3', 'C#4' 'Db4']
note.enharmonics('Db') // => ['C#', 'Db', 'Ebbb'])

note.simplify(note) ⇒ String

Get a simpler enharmonic note name from a note if exists

Kind: static method of note
Returns: String - the simplfiied note (if not found, return same note)

ParamTypeDescription
noteStringthe note to simplify

Example

var note = require('tonal-note')
note.simplify('B#3') // => 'C4'

FAQs

Package last updated on 31 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc